ScaledUserViewWindow

part of wslib

a user configurable but standardized window containing a ScaledUserView

and sliders for scrolling and zooming.

also see: ScaledUserView

Creation

ScaledUserViewWindow ( name, bounds, fromBounds, viewOffset )

ScaledUserView.window ( name, bounds, fromBounds, viewOffset )

the name and bounds arguments work the same way as in every SCWindow

The fromBounds are passet through to the ScaledUserView.

The viewOffset can be a Point, a Number or an Array. It describes the position of the leftTop corner of the ScaledUserView.

All methods which can be called to ScaledUserView can also be called to ScaledUserViewWindow, which will route them to its ScaledUserView.

w = ScaledUserViewWindow( );

w.drawFunc = { Pen.width = 0.05; Pen.line( 0.1@0.1, 0.9@0.9 ).stroke; };

// now move the sliders and see what happens

w.gridLines = [10, 4];

(

// grab and move points

w.clearDrawFuncs;

p = { Point.rand( 1.0, 1.0 ) } ! 10;

a = nil; // selected point

w.drawFunc = {

Color.green(0.5).alpha_(0.75).set;

p.do({ |pt| Pen.addArc( pt, 0.05, 0, 2pi ).fill; });

if( a.notNil ) { Color.red.set; Pen.addArc( p[a], 0.05, 0, 2pi ).stroke };

};

w.mouseDownAction = { |v, sx, sy| a = p.detectIndex({ |pt| pt.dist( sx@sy ) <= 0.05 }); };

w.mouseMoveAction = { |v, sx, sy, m, x, y, inside| if(inside and: a.notNil) { p[a] = (sx@sy) }; };

)

instance variables

window

holds to the SCWindow itself. Use it to add your own views, set the bounds, change the background etc.

userView

holds to the ScaledUserView inside the window.

scaleSliders

holds the two (small) scale sliders in an array. The sliders are all SmoothSlider.

moveSliders

holds the two scroll sliders in an array

viewOffset

holds the view offset as set at creation. Cannot be changed.

maxZoom

maximum scaling for the sliders (default 8 )

onClose

gets and sets an onClose action (don't replace that of the window directly; use this one)

drawHook

gets and sets a drawHook function (don't replace that of the window directly; use this one)